/*find i --> li = max lk, j --> rj = min rk
if li > rj
	all (i, j) ri < lj --> min rj - li 
else 
	ans = ri - lj + 1*/
#include<bits/stdc++.h>
using namespace std;

struct node1 {
	int l, r;
	friend bool operator < (node1 x, node1 y) {return x.l < y.l;}
};
struct node2 {
	int l, r;
	friend bool operator < (node2 x, node2 y) {return x.r < y.r;}
};
set<node1>q1;
set<node2>q2;
set<int> a;
vector<pair<int, int> >v;
signed main() {
	freopen("stone.in", "r", stdin);
	freopen("stone.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int Q;
	cin >> Q;
	if(Q > 50000) {
		while(Q--) {
			char op;
			cin >> op;
			int l, r;
			cin >> l >> r;
			if(op == 'A') {
				q1.insert((node1) {l, r});
				q2.insert((node2) {l, r});
				
				auto pre = q1.lower_bound((node1) {l, r});
				if(pre != q1.begin()) {
					pre--;
					a.insert(r - (*pre).l);
				}
				
				auto nxt = q1.lower_bound((node1) {l, r});
				if(nxt != --q1.end()) {
					++nxt;
					a.insert((*nxt).r - l);
				}
			}
			else {
				
				auto pre = q1.lower_bound((node1) {l, r});
				if(pre != q1.begin()) {
					pre--;
					a.erase(r - (*pre).l);
				}
				
				auto nxt = q1.lower_bound((node1) {l, r});
				if(nxt != --q1.end()) {
					++nxt;
					a.erase((*nxt).r - l);
				}
				q1.erase((node1) {l, r});
				q2.erase((node2) {l, r});
			}
			int L = (*q1.rbegin()).l;
			int R = (*q2.begin()).r;
			if(q1.size() == 1) cout << (*q1.begin()).r - (*q1.begin()).l << endl;
			else if(L < R) {
				int ll = (*q2.begin()).l;
				int rr = (*q1.rbegin()).r;
				cout << rr - ll << endl;
			}
			else {
				cout << *a.begin() << endl;
			}
		}
		return 0;
	}
	while(Q--) {
		char op;
		cin >> op;
		int l, r;
		cin >> l >> r;
		if(op == 'A') {
			q1.insert((node1) {l, r});
			q2.insert((node2) {l, r});
		}
		else {
			q1.erase((node1) {l, r});
			q2.erase((node2) {l, r});
		}
		int L = (*q1.rbegin()).l;
		int R = (*q2.begin()).r;
 		if(q1.size() == 1) cout << (*q1.begin()).r - (*q1.begin()).l << endl;
		else if(L < R) {
			int ll = (*q2.begin()).l;
			int rr = (*q1.rbegin()).r;
			cout << rr - ll << endl;
		}
		else {
			v.clear();
			for(auto x : q1) v.push_back(make_pair(x.l, x.r));
			int res = 1e9;
			for(int i = 0; i < (int)(v.size()); i++) {
				for(int j = 0; j < (int)(v.size()); j++) {
					if(v[i].second <= v[j].first) res = min(res, v[j].second - v[i].first);
				}
			}
			cout << res << endl;
		}
	}
}
